home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12580 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.2 KB  |  141 lines

  1. Path: hermes.is.co.za!news
  2. From: Itsik Rubin <yr@isis.co.za>
  3. Newsgroups: comp.lang.c++
  4. Subject: Correctness of RTTI Info in Borland C++ in a multi threaded envirnment
  5. Date: Wed, 20 Mar 1996 19:26:48 +0200
  6. Organization: No organisation supplied
  7. Message-ID: <31503FD8.4A7A@isis.co.za>
  8. NNTP-Posting-Host: yr.isis.co.za
  9. Mime-Version: 1.0
  10. Content-Type: text/html; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.0GoldB1 (WinNT; I)
  13. Content-Disposition: inline; filename="mail.htm"
  14.  
  15. <BASE HREF="file:///D|/builds/rps00933/rtti/mail.htm">
  16.  
  17. <html>
  18. <head>
  19.    <title></title>
  20.    <meta name="GENERATOR" content="Mozilla/2.0GoldB1 (Win32)">
  21. </head>
  22. <body>
  23.  
  24. <p>Hello, </p>
  25.  
  26. <p>I am using Borland C++ Version 4.51 under Windows NT I am developping
  27. a 32 bit application that is intended for Windows NT and I use extensively
  28. multi threading as well as the streaming mechanism provided in the Borland
  29. class library.</p>
  30.  
  31. <p>This is used for inter thread , inter process and inter processor (over
  32. a LAN) communication.</p>
  33.  
  34. <p>The developped system is required to run continuously 24 hours a day
  35. 7 days a week.</p>
  36.  
  37. <p>Approximatly once a day I run into a problem where during the operation
  38. of the system a stream becomes corrupted. When I make the following change
  39. to the opstream::WriteData method inside objstrm.cpp (Borland Class library)
  40. I get logs in both places (marked 1 and 2).</p>
  41.  
  42. <p>Based on my observation the first _TYPENAME(strmr) is erronous whereas
  43. the second one returns correct results.</p>
  44.  
  45. <p>This points to problems within the RTTI mechanism. The following questions
  46. (at least) need answer: </p>
  47.  
  48. <p>1. Is typeinfo object, which is part of the Borland C++ RTTI, multi-thread
  49. safe? </p>
  50.  
  51. <p>2. Has anyone else encounted this problem? </p>
  52.  
  53. <p>3. Is there a fix for this problem? </p>
  54.  
  55. <p>The modified method in objstrm.cpp: (The code preceeded by /**/ is an
  56. addition.</p>
  57.  
  58. <p>void opstream::writeData( const TStreamableBase *t, ModuleId mid )</p>
  59.  
  60. <p>{</p>
  61.  
  62. <ul>
  63. <p>if( good() )</p>
  64.  
  65. <p>{ </p>
  66.  
  67. <ul>
  68. <p>registerObject( CONST_CAST(TStreamableBase *,t) );</p>
  69.  
  70. <p>const ObjectBuilder *res = types->Lookup( mid, _TYPENAME(t) );</p>
  71.  
  72. <p>CHECKX(res,_TYPENAME(t)); </p>
  73.  
  74. <p>TStreamer *strmr = res->Builder(CONST_CAST(TStreamableBase *,t));</p>
  75. </ul>
  76.  
  77. <p>/**/ if ( t )</p>
  78.  
  79. <p>/**/ { </p>
  80.  
  81. <p>/**/ char check [100] ;</p>
  82.  
  83. <p>/**/ char strmtname [100] ;</p>
  84.  
  85. <p>/**/ strcpy ( strmtname, _TYPENAME(strmr) ); </p>
  86.  
  87. <p>/**/ sprintf ( check , "%s::Streamer" , _TYPENAME(t) ) ;</p>
  88.  
  89. <p>/**/ if ( strcmp ( check , strmtname ) != 0 )</p>
  90.  
  91. <p>/**/ { </p>
  92.  
  93. <p>/**/ char temp [200] ; </p>
  94.  
  95. <p>/**/ sprintf ( temp , "WriteData lookup error %s not equal to %s"
  96. , check , strmtname ) ; </p>
  97.  
  98. <p>/* (1) */ cout << temp << endl;</p>
  99.  
  100. <p>/**/ if ( strcmp ( strmtname, _TYPENAME(strmr) ) != 0 )</p>
  101.  
  102. <p>/**/ {</p>
  103.  
  104. <p>/**/ sprintf ( temp, "WriteData changed typeinfo %s to %s",
  105. strmtname, _TYPENAME(strmr) ) ;</p>
  106.  
  107. <p>/* (2) */ cout << temp << endl;</p>
  108.  
  109. <p>/**/ }</p>
  110.  
  111. <p>/**/ }</p>
  112.  
  113. <p>/**/ } </p>
  114.  
  115. <ul>
  116. <p>writeWord32( strmr->ClassVersion() );</p>
  117.  
  118. <p>strmr->Write( *this );</p>
  119.  
  120. <p>delete strmr;</p>
  121. </ul>
  122.  
  123. <p>}</p>
  124. </ul>
  125.  
  126. <p>}</p>
  127.  
  128. <ul>
  129. <p></p>
  130.  
  131. <p>A response will be greatly appreciated. </p>
  132.  
  133. <p>Regards, </p>
  134.  
  135. <p>Itsik Rubin</p>
  136. </ul>
  137.  
  138. </body>
  139. </html>
  140.  
  141.